package gotype

import (
	"fmt"
	"time"
)

type DateTime time.Time

func (t DateTime) MarshalJSON() ([]byte, error) {
	var stamp = fmt.Sprintf("\"%s\"", time.Time(t).Format("2006-01-02 15:04:05"))
	return []byte(stamp), nil
}

func (t *DateTime) UnmarshalJSON(b []byte) error {
	tmp, err := time.Parse("\"2006-01-02 15:04:05\"",string(b))
	if err != nil {
		return err
	}
	*t = DateTime(tmp)
	return nil
}
